package array

// https://leetcode-cn.com/problems/flipping-an-image/
// 翻转 + 反转 图片
// 直接遍历即可
// 时间复杂度: O(nm)
func reverseOne(i int) int {
	return 1 - i
}

func FlipAndInvertImage(A [][]int) [][]int {
	for _, currentSlice := range A {
		start, end := 0, len(currentSlice)-1
		for start <= end {
			currentSlice[start], currentSlice[end] = reverseOne(currentSlice[end]), reverseOne(currentSlice[start])
			start++
			end--
		}
	}
	return A
}
